#ifndef PARAMETERSETDIALOG_H
#define PARAMETERSETDIALOG_H
#include "global_defines.h"
#include "settingfile.h"
#include "file/deletefile.h"
#include <QFileDialog>
#include <QDialog>
#include <QMessageBox>
#include <QComboBox>
#include <QRegExp>
#include <QRegExpValidator>
#include <QButtonGroup>
#include "devices/usbgps.h"
#include "devices/quectelgps.h"

namespace Ui
{
class ParameterSetDialog;
}

class ParameterSetDialog : public QDialog
{
    Q_OBJECT

public:
    explicit ParameterSetDialog(QWidget *parent = nullptr);
    ~ParameterSetDialog();
    SOFTWARESETTINGS getParaSettings();
    void setParaSettings(SOFTWARESETTINGS settings, bool isWorking);
    void setDispsettings(SOFTWARESETTINGS settings);

signals:
    void PB_laser_On_Clicked();
    void PB_motor_On_Clicked();
    void PB_wiper_On_Clicked();

    void PB_laser_Off_Clicked();
    void PB_motor_Off_Clicked();
    void PB_wiper_Off_Clicked();

    void PB_getTemperature_Clicked();
    void ATM_InfoWanted();
    void MotorpushButton_clicked(const double MotorAngle);
    void GetGPSInfo_clicked();

    void save_settings_button_clicked(const QString &s);
    void save_settings_canceled();
    void save_clicked();
    void save_as_settings_button_clicked(const QString &s);
    void save_as_clicked();
    void load_settings_button_clicked(const QString &s);
    void load_settings_canceled();
    void load_clicked();
    void reset_settings_button_clicked(const QString &s);
    void motor_test_button_clicked(const QString &s);
    void delete_file_button_clicked();
    void closeLaser();


public slots:
    void SetLaserFlag(const bool Status);
//    void SetMotorFlag(const bool Status);
    void SetWiperFlag(const bool Status);
    void SetLongitude(const double longitude);
    void SetLatitude(const double latitude);
    void SetGPSPortMessage(const QString message);
    void SetSysTemper(double systemp);      // ˢ�»������¶���Ϣ
    void SetlaserDTemp(const double T);
    void SetlaserCTemp(const double T);

    void displayTemperature(QString Humidity);  // ��ʪѹ�������Ĵ��� �¶�
    void displayPressure(QString Pressure);     // ��ʪѹ�������Ĵ��� ѹǿ
    void displayHumidity(QString Humidity);     // ��ʪѹ�������Ĵ��� ʪ��

private slots:

    void on_detectModeComboBox_activated(int index);
    void on_anglekeyRadioButton_clicked(bool checked);
    void on_circlekeyRadioButton_clicked(bool checked);
    void on_autoCreateDateDirCheckBox_clicked(bool checked);

    void on_pathModifyPushButton_clicked();
    void on_saveSettingsPushButton_clicked();
    void on_saveasSettingsPushButton_clicked();
    void on_loadSettingsPushButton_clicked();
    void on_confirmSetPushButton_clicked();
    void on_cancelSetPushButton_clicked();
    void on_resetSettingsPushButton_clicked();

    void on_laserWaveLengthdoubleSpinBox_valueChanged(double arg1);
    void on_laserAOMdoubleSpinBox_valueChanged(double arg1);
    void on_triggerLevelSpinBox_valueChanged(int arg1);

    void on_SpinBox_nPointsMirror_valueChanged(int arg1);
    void on_ComboBox_nRangeBin_currentIndexChanged(int index);
    void on_ComboBox_nPointsPerRB_currentIndexChanged(int index);
    void on_nPulsesAccSpinBox_valueChanged(int arg1);
    void on_nPointsObjFreqdoubleSpinBox_valueChanged(double arg1);
    void on_nPointsObjFreqdoubleSpinBox_editingFinished();
    void on_nDirsVectorCalSpinBox_valueChanged(int arg1);
    void on_azAngleStartdoubleSpinBox_valueChanged(double arg1);
    void on_azAngleStepdoubleSpinBox_valueChanged(double arg1);
    void on_motorSpeeddoubleSpinBox_valueChanged(double arg1);
    void on_doubleSpinBoxheadangle_valueChanged(double arg1);
    void on_elevationAngledoubleSpinBox_valueChanged(double arg1);
    void on_intervalTimedoubleSpinBox_valueChanged(double arg1);
    void on_groupTimedoubleSpinBox_valueChanged(double arg1);
    void on_nDirsPerFileSpinBox_valueChanged(int arg1);
    void on_angleNumSpinBox_valueChanged(int arg1);
    void on_circleNumdoubleSpinBox_valueChanged(double arg1);
    void on_SpinBoxsnrThreshold_valueChanged(int arg1);

    void checkDataFilePath();

    void on_laserLocalPowerSpinBox_valueChanged(int arg1);

    // void on_laserPulseEnergySpinBox_valueChanged(int arg1);

    void on_laserRPFdoubleSpinBox_valueChanged(double arg1);

    void on_laserPulseWidthSpinBox_valueChanged(int arg1);

    void on_dispfullscreen_stateChanged(int state);
    void on_dispcontentcomboBox_currentIndexChanged(int arg1);
    void on_dispwindfeather_stateChanged(int state);
    void on_disp_background_currentIndexChanged(int arg1);
    void on_disp_max_height_num_valueChanged(int num);
    void on_checkBoxdenoise_stateChanged(int status);
    void on_checkBoxlimitFreq_stateChanged(int status);
    void on_disp_no_avg_clicked(bool status);
    void on_disp_s_avg_clicked(bool status);
    void on_disp_m_avg_clicked(bool status);
    void on_disp_s_val_valueChanged(int num);
    void on_disp_m_val_valueChanged(int num);

    void on_filesavetype_currentIndexChanged(int arg1);

//    void on_checkBoxlaser_stateChanged(int status);

//    void on_checkBoxmotor_stateChanged(int status);

//    void on_checkBoxadq_stateChanged(int status);

    void on_DeleteFilePushButton_clicked();

    void on_deleteFileTimeComboBox_activated(int index);

//   void on_timelineEdit_1_textChanged(const QString &arg1);

//    void on_timelineEdit_3_textChanged(const QString &arg1);

//    void on_timelineEdit_2_textChanged(const QString &arg1);

    void on_timelineEdit_userTimeChanged(const QTime &time);

    void on_timelinedoubleSpinBox_valueChanged(const double &arg1);

    void on_autoDeleteFilecheckBox_clicked(bool checked);

    void on_pushButton_laser_On_clicked();

    void on_pushButton_laser_Off_clicked();

    void on_pushButton_motor_On_clicked();

    void on_pushButton_motor_Off_clicked();

    void on_pushButton_wiper_On_clicked();

    void on_pushButton_wiper_Off_clicked();

    void on_pushButton_getTemperature_clicked();

    void on_MotorpushButton_clicked();

    void on_pushButton_GetGPSInfo_clicked();

    void on_pushButton_Temperature_clicked();

    void on_pushButton_Humidity_clicked();

    void on_pushButton_Pressure_clicked();

    void on_doubleSpinBoxAngleToNorth_valueChanged(double arg1);

    void on_laserAutoClosecheckBox_clicked(bool checked);

    void on_laserAutoClosepushButton_clicked();

private:
    Ui::ParameterSetDialog *ui;
    void refreshDisp();
    SOFTWARESETTINGS paraSettings;
    double getVoltageTriggerLevel();
    double getPreTriggerTimeLength();
    double getMirrorWidthTime();
    double getRangeResolution();
    double getMinDetectRange();
    double getMaxDetectRange();
    SettingFile *paraSettingFile;
    QButtonGroup *groupButton_avgDisp;
    deletefile *deleteFile;
    quint64 getDiskFreeSpace(QString driver);
    USBGPS * usb_GPS;
    QuectelGPS * quectel_GPS;
};

#endif // PARADIALOG_H
